package com.taoyuan.hotel.controller;


import com.taoyuan.hotel.entity.Admin;
import com.taoyuan.hotel.entity.Check;
import com.taoyuan.hotel.service.intf.AdminService;
import com.taoyuan.hotel.service.intf.CheckService;
import com.taoyuan.hotel.vo.PageBean;
import com.taoyuan.hotel.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/api/admin/")
public class AdminController {
    @Autowired
    private AdminService service;
    //新增
    @PostMapping("save.do")
    public R save(Admin admin){
        return service.save(admin);
    }
    //删除
    @PostMapping("del.do")
    public R del(int id) {
        return service.del(id);
    }
    //修改
    @PostMapping("update.do")
    public R update(Admin admin) {
        return service.update(admin);
    }
    //条件查询
    @GetMapping("pagewhere.do")
    public PageBean pageWhere(String name, int page, int limit) {
        return service.queryPageWhere(name,page,limit);
    }
    //批量删除 JSON格式
    @PostMapping("delbatch.do")
    public R  del(@RequestBody int[] ids){
        return service.delBatch(ids);
    }

    @GetMapping("login.do")
    public R login(Admin admin, HttpSession session){
        return service.login(admin,session);
    }

}
